/*   */
$(function () {
    initYljaddtxt();
    initTableData();

    function initYljaddtxt() {
        //一类积案堆叠条形图
        let myChart = echarts.init(document.getElementById('yljaddtxt'));
        CoreUtil.sendPost("/statistics/jianjinzhan_ddtxt", null, function (res) {
            let yAxis_category_data = res.data.yAxis_category_data;
            let series_jiancha_data = res.data.series_jiancha_data;
            let series_shenli_data = res.data.series_shenli_data;
            let series_zhixing_data = res.data.series_zhixing_data;
            let option = {
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'shadow'
                    }
                },
                legend: {},
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                xAxis: {
                    type: 'value'
                },
                yAxis: {
                    type: 'category',
                    data: yAxis_category_data
                },
                series: [
                    {
                        name: '检查',
                        type: 'bar',
                        stack: 'total',
                        label: {
                            show: true
                        },
                        emphasis: {
                            focus: 'series'
                        },
                        data: series_jiancha_data

                    },
                    {
                        name: '审理',
                        type: 'bar',
                        stack: 'total',
                        label: {
                            show: true
                        },
                        emphasis: {
                            focus: 'series'
                        },
                        data: series_shenli_data

                    },
                    {
                        name: '执行',
                        type: 'bar',
                        stack: 'total',
                        label: {
                            show: true
                        },
                        emphasis: {
                            focus: 'series'
                        },
                        data: series_zhixing_data

                    }
                ]
            };

            if (option && typeof option === 'object') {
                myChart.setOption(option);
            }
            window.addEventListener('resize', myChart.resize);
        });
        // let yAxis_category_data = ['新鸿宣广告', '洪宇钢板', '泰祥拆除', '新望科技',
        //     '园林绿化', '机车车辆', '地源绿化', '岩田图文', '西部新兴', '城市管理', '新黎明消防', '浙企实业'];
        // let series_jiancha_data = [307, 196, 176, 183, 192, 320, 302, 301, 334, 390, 330, 320];
        // let series_shenli_data = [120, 132, 101, 134, 90, 230, 307, 196, 176, 183, 192, 210];
        // let series_zhixing_data = [220, 182, 191, 196, 176, 183, 192, 210, 234, 290, 330, 310];
    }

    function initTableData() {
        $("#levelOneJianData_tbody").empty(); // 清空原有数据
        CoreUtil.sendPost("/statistics/jianjinzhan", {"swjgDm": ""}, function (res) {
            let jianTableDatas = res.data.tableDatas;
            let dataScope = res.data.dataScope;
            let tableHjDatas = res.data.tableHjDatas;//合计行

            $.each(jianTableDatas, function (index, item) {
                let swjgmcTD = "<td style='text-align: center'>" + item.SWJGMC + "</td>";
                if ("all" === dataScope) {
                    swjgmcTD = "<td style='text-align: center'>" +
                        '<a href="javascript:void(0);" style="color:darkorchid" onclick="xiazuanQ(' + item.SWJGDM + ')">' +
                        item.SWJGMC + "</a></td>";
                }
                let swjgDm = item.SWJGDM;
                let rowHtml = "";
                // if ("12101009100" === swjgDm) {
                    rowHtml = "<tr>" +
                        // <a href="javascript:void(0);" style="color:darkorchid" onclick="xiazuanQ(1)" ;>稽查局</a>
                        swjgmcTD
                        + "<td style='text-align: center'>" +
                        '<a href="javascript:void(0);" style="color:darkorchid" onclick="skipYljaPage(' + '2,' + item.SWJGDM +  ')">' + item.JCSL + "</a></td>" +
                        "<td style='text-align: center'>" +
                        '<a href="javascript:void(0);" style="color:darkorchid" onclick="skipYljaPage(' + '3,' +item.SWJGDM +  ')">' + item.SLSL + "</a></td><td style='text-align: center'>" +
                        '<a href="javascript:void(0);" style="color:darkorchid" onclick="skipYljaPage(' + '4,' + item.SWJGDM + ')">' + item.ZXSL + "</a></td>" +
                        "<td style='text-align: center'>" +
                        '<a href="javascript:void(0);" style="color:darkorchid" onclick="skipYljaPage(' + '901,' + item.SWJGDM + ')">' + item.BJSL + "</a></td><td style='text-align: center'>" +
                        '<a href="javascript:void(0);" style="color:darkorchid" onclick="skipYljaPage(' + '5,' + item.SWJGDM + ')">' + item.JASL + "</a></td>" +
                        "<td style='text-align: center'>" + item.ylother + "</td><td style='text-align: center'>" + item.yltotal + "</td>" +
                        "<td style='text-align: center'>" +
                        '<a href="javascript:void(0);" style="color:darkorchid" onclick="skipEljaPage(' + '2,' + item.SWJGDM + ')">' + item.ELJCSL + "</a></td><td style='text-align: center'>" +
                        '<a href="javascript:void(0);" style="color:darkorchid" onclick="skipEljaPage(' + '3,' + item.SWJGDM + ')">' + item.ELSLSL + "</a></td>" +
                        "<td style='text-align: center'>" +
                        '<a href="javascript:void(0);" style="color:darkorchid" onclick="skipEljaPage(' + '4,' + item.SWJGDM + ')">' + item.ELZXSL + "</a></td><td style='text-align: center'>" +
                        '<a href="javascript:void(0);" style="color:darkorchid" onclick="skipEljaPage(' + '901,' +item.SWJGDM +  ')">' + item.ELBJSL + "</a></td>" +
                        "<td style='text-align: center'>" +
                        '<a href="javascript:void(0);" style="color:darkorchid" onclick="skipEljaPage(' + '5,' +item.SWJGDM +  ')">' + item.ELJASL + "</a></td><td style='text-align: center'>" + item.elother + "</td>" +
                        "<td style='text-align: center'>" + item.eltotal + "</td>" +
                        "</tr>";
                // } else {
                //     rowHtml = "<tr>" +
                //         // <a href="javascript:void(0);" style="color:darkorchid" onclick="xiazuanQ(1)" ;>稽查局</a>
                //         swjgmcTD
                //         + "<td style='text-align: center'>" + item.JCSL + "</td>" +
                //         "<td style='text-align: center'>" + item.SLSL + "</td><td style='text-align: center'>" + item.ZXSL + "</td>" +
                //         "<td style='text-align: center'>" + item.BJSL + "</td><td style='text-align: center'>" + item.JASL + "</td>" +
                //         "<td style='text-align: center'>" + item.ylother + "</td><td style='text-align: center'>" + item.yltotal + "</td>" +
                //         "<td style='text-align: center'>" + item.ELJCSL + "</td><td style='text-align: center'>" + item.ELSLSL + "</td>" +
                //         "<td style='text-align: center'>" + item.ELZXSL + "</td><td style='text-align: center'>" + item.ELBJSL + "</td>" +
                //         "<td style='text-align: center'>" + item.ELJASL + "</td><td style='text-align: center'>" + item.elother + "</td>" +
                //         "<td style='text-align: center'>" + item.eltotal + "</td>" +
                //         "</tr>";
                // }
                $("#levelOneJianData_tbody").append(rowHtml);
            });
            //合计行
            let hjData = tableHjDatas[0];
            const hjrowhtml = "<tr>"
                + "<td style='text-align: center'>合计</td>"
                + "<td style='text-align: center'>" + hjData.yljctotal + "</td>"
                + "<td style='text-align: center'>" + hjData.ylsltotal + "</td>"
                + "<td style='text-align: center'>" + hjData.ylzxtotal + "</td>"
                + "<td style='text-align: center'>" + hjData.ylbjtotal + "</td>"
                + "<td style='text-align: center'>" + hjData.yljatotal + "</td>"
                + "<td style='text-align: center'>" + hjData.ylothertotal + "</td>"
                + "<td style='text-align: center'>" + hjData.ylhjtotal + "</td>"
                + "<td style='text-align: center'>" + hjData.eljctotal + "</td>"
                + "<td style='text-align: center'>" + hjData.elsltotal + "</td>"
                + "<td style='text-align: center'>" + hjData.elzxtotal + "</td>"
                + "<td style='text-align: center'>" + hjData.elbjtotal + "</td>"
                + "<td style='text-align: center'>" + hjData.eljatotal + "</td>"
                + "<td style='text-align: center'>" + hjData.elothertotal + "</td>"
                + "<td style='text-align: center'>" + hjData.elhjtotal + "</td>"
                + "</tr>";
            $("#levelOneJianData_tbody").append(hjrowhtml);
        });
    }
});

function xiazuanQ(swjgDm) {
    $("#levelTwoJianData_tbody").empty(); // 清空原有数据
    CoreUtil.sendPost("/statistics/jianjinzhan", {"swjgDm": swjgDm}, function (res) {
        let jianTableDatas = res.data.tableDatas;
        let tableHjDatas = res.data.tableHjDatas;//合计行
        $.each(jianTableDatas, function (index, item) {
            let swjgmcTD = "<td style='text-align: center'>" + item.SWJGMC + "</td>";
            let rowHtml = "<tr>" +
                // <a href="javascript:void(0);" style="color:darkorchid" onclick="xiazuanQ(1)" ;>稽查局</a>
                swjgmcTD
                + "<td style='text-align: center'>" + item.JCSL + "</td>" +
                "<td style='text-align: center'>" + item.SLSL + "</td><td style='text-align: center'>" + item.ZXSL + "</td>" +
                "<td style='text-align: center'>" + item.BJSL + "</td><td style='text-align: center'>" + item.JASL + "</td>" +
                "<td style='text-align: center'>" + item.ylother + "</td><td style='text-align: center'>" + item.yltotal + "</td>" +
                "<td style='text-align: center'>" + item.ELJCSL + "</td><td style='text-align: center'>" + item.ELSLSL + "</td>" +
                "<td style='text-align: center'>" + item.ELZXSL + "</td><td style='text-align: center'>" + item.ELBJSL + "</td>" +
                "<td style='text-align: center'>" + item.ELJASL + "</td><td style='text-align: center'>" + item.elother + "</td>" +
                "<td style='text-align: center'>" + item.eltotal + "</td>" +
                "</tr>";
            $("#levelTwoJianData_tbody").append(rowHtml);
        });
        //合计行
        let hjData = tableHjDatas[0];
        const hjrowhtml = "<tr>"
            + "<td style='text-align: center'>合计</td>"
            + "<td style='text-align: center'>" + hjData.yljctotal + "</td>"
            + "<td style='text-align: center'>" + hjData.ylsltotal + "</td>"
            + "<td style='text-align: center'>" + hjData.ylzxtotal + "</td>"
            + "<td style='text-align: center'>" + hjData.ylbjtotal + "</td>"
            + "<td style='text-align: center'>" + hjData.yljatotal + "</td>"
            + "<td style='text-align: center'>" + hjData.ylothertotal + "</td>"
            + "<td style='text-align: center'>" + hjData.ylhjtotal + "</td>"
            + "<td style='text-align: center'>" + hjData.eljctotal + "</td>"
            + "<td style='text-align: center'>" + hjData.elsltotal + "</td>"
            + "<td style='text-align: center'>" + hjData.elzxtotal + "</td>"
            + "<td style='text-align: center'>" + hjData.elbjtotal + "</td>"
            + "<td style='text-align: center'>" + hjData.eljatotal + "</td>"
            + "<td style='text-align: center'>" + hjData.elothertotal + "</td>"
            + "<td style='text-align: center'>" + hjData.elhjtotal + "</td>"
            + "</tr>";
        $("#levelTwoJianData_tbody").append(hjrowhtml);
    });
    let div1 = document.getElementById("levelOneJianData");
    let div2 = document.getElementById("levelTwoJianData");
    div1.style.display = "none";
    div2.style.display = "block";

}

function returnxiazuanQ() {
    let div1 = document.getElementById("levelOneJianData");
    let div2 = document.getElementById("levelTwoJianData");
    div1.style.display = "block";
    div2.style.display = "none";
}

function zhankaitubiao() {
    let div1 = document.getElementById("levelOneJianData");
    let div2 = document.getElementById("levelTwoJianData");
    let div3 = document.getElementById("yljaddtxt_div");
    div1.style.display = "none";
    div2.style.display = "none";
    $("#yljaddtxt_div").removeClass("span3");
    $("#yljaddtxt_div").addClass("span9");
}

function skipYljaPage(ajztDm,swjgDm) {
    skipOpen("/index/attention/firstClassBacklogCase?ajztDm=" + ajztDm+"&swjgDm="+swjgDm, "80105", "一类积案");
}

function skipEljaPage(ajztDm,swjgDm) {
    skipOpen("/index/attention/secondClassBacklogCase?ajztDm=" + ajztDm+"&swjgDm="+swjgDm, "80106", "二类积案");
}
